#include <QWidget>

#include <QPainter>
#include <QPaintEvent>
#include <QMouseEvent>

#include <opencv/cv.h>
#include <opencv/highgui.h>

#ifndef QVIEW_SELECTOR
#define QVIEW_SELECTOR

class QViewSelector:public QWidget
{

	public:
		QViewSelector();
				
		void setImage(cv::Mat& image);
		void setKeysPoints(cv::Mat& keysPoints,cv::Mat& previousKeysPoints);
		void setLinks(cv::Mat& links);
		
		void move_box(int dx,int dy);

		void get_box_xy(cv::Mat_<float>& b);
		void set_box_xy(cv::Mat_<float>& b);		
		void get_box_xywh(cv::Mat_<float>& b);
		void set_box_xywh(cv::Mat_<float>& b);	

		void get_box(cv::Mat_<int>& b);
		void set_box(cv::Mat_<int>& b,int marges=0);
	
		void displayLinks(bool enable);
		void displayKeys(bool enable);

		cv::Mat& getMask();
		cv::Mat& getRoi();

	private:
		bool display_links,display_keys;

		cv::Mat frame,frame_rgb;
		cv::Mat mask;
		cv::Mat roi;
		cv::Mat_<int> links;
		cv::Mat_<float> keyspoints,previousKeysPoints;
		int box[4];

	protected:
		void paintEvent(QPaintEvent * e);
		void mouseMoveEvent(QMouseEvent * e);
		void mousePressEvent(QMouseEvent * e);	
		
};


#endif
